<template>
  <div class="article-container">
    <div class="article-header">
      <h1 class="article-title">{{ title }}</h1>
      <div class="article-meta">
        <span class="article-author">作者: {{ article.author }}</span>
        <span class="article-date">发布日期: {{ formattedDate }}</span>
      </div>
    </div>

    <div class="article-content" v-html="content"></div>
  </div>
</template>

<script>
export default {
  name: "ArticleView",
  props: {
    articleId: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
    content: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      article: {
        author: "午月文化",
        date: "2023-05-15",
      },
    };
  },
  computed: {
    formattedDate() {
      // 简单的日期格式化
      const date = new Date(this.article.date);
      return `${date.getFullYear()}年${
        date.getMonth() + 1
      }月${date.getDate()}日`;
    },
  },
};
</script>

<style scoped>
.article-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  font-family: "Arial", sans-serif;
  line-height: 1.6;
  color: #333;
}

.article-header {
  margin-bottom: 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
}

.article-title {
  font-size: 28px;
  margin-bottom: 10px;
  color: #2c3e50;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #7f8c8d;
}

.article-content {
  margin-top: 20px;
}

.article-content >>> h2 {
  font-size: 22px;
  margin: 25px 0 15px;
  color: #34495e;
}

.article-content >>> p {
  margin-bottom: 15px;
}

.article-content >>> ul {
  padding-left: 20px;
  margin-bottom: 15px;
}

.article-content >>> pre {
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  overflow-x: auto;
}

.article-content >>> code {
  font-family: "Courier New", monospace;
  color: #c7254e;
}
</style>